package com.west_traveler.viewpager_adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.west_traveler.entity.entity_find_second_hot_recommend.SecondHotRecommendAlbum;
import com.west_traveler.entity.entity_find_second_hot_recommend.SecondHotRecommendDetail;
import com.west_traveler.find_page_fragment.SecondAlbumFragment;
import com.west_traveler.find_page_fragment.SecondDetailFragment;

import java.util.List;

/**
 * Description:
 * created at 2016/12/6 22:59
 *
 * @author: 黄昌友
 */

public class SecondAlbumViewPagerAdapter extends FragmentStatePagerAdapter {

    private List list;
    private String[] name = new String[2];

    public SecondAlbumViewPagerAdapter(FragmentManager fm, List list) {
        super(fm);
        this.list = list;
        name[0] = "详情";
        name[1] = "节目";
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return SecondDetailFragment.getInstance((SecondHotRecommendDetail.DataBean) list.get(position));
        } else {
            return SecondAlbumFragment.getInstance(((SecondHotRecommendAlbum.DataBean) list.get(position)));
        }
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (position == 0) {
            return name[position];
        } else {
            return name[position] + "(" + ((SecondHotRecommendAlbum.DataBean) list.get(position)).getTracks().getTotalCount() + ")";
        }
    }
}
